Home > DotNet, GoDaddy > How to send mail using Gmail in ASP.Net with Godaddy Server?

How to send mail using Gmail in ASP.Net with Godaddy Server?


Cannot send email in ASP.Net through GoDaddy Servers?

In ASP.Net we can sennd mail to anyone using gmail smtp server. We have created codes for sending mail using gmail credentials and it is working fine in local. But when we uploaded to the server we are unable to send mail using the options. The thing is that we are using GoDaddy Server as hosting server and it is not supported the gmail smtp server to send mail.

How to Send mail in ASP.Net with GoDaddy Server

Inorder to send mail using ASP.Net we got a support from godaddy department and now it is working fine. Following are the codes for sending mail in ASP.Net with GoDaddy Server:

using System.Web.Mail;

public static void sendEmail(EmailDetails objEmail)
        {
            try
            {
                string SERVER = ConfigurationSettings.AppSettings["MailServer"].ToString();

                MailMessage oMail = new System.Web.Mail.MailMessage();
                oMail.From = objEmail.From;
                oMail.To = objEmail.To;
                oMail.Cc = ConfigurationSettings.AppSettings["AdminEmailID"].ToString();
                oMail.Subject = objEmail.Subject;
                oMail.BodyFormat = MailFormat.Html;   // enumeration
                oMail.Priority = MailPriority.High;   // enumeration
                oMail.Body = objEmail.Message;
                SmtpMail.SmtpServer = SERVER;
                SmtpMail.Send(oMail);
                oMail = null; // free up resources
            }
            catch (Exception ex)
            {
                throw;
            }
        }

Here we have a object ‘objEmail’ which holds the mail details such as from address, to address, subject etc. We have to use System.Web.Mail class for send mail. Here we are taking server details from web.config as given below.

  <add key="MailServer" value="mail.gmail.com" />

 

When we are running in local system the above code is working fine, but when we uploaded to goDaddy server send mail is not working. Then we have to change mail server details in web.config to following one.

<add key="MailServer" value="relay-hosting.secureserver.net" />
Categories: DotNet, GoDaddy Tags: ,
  1. September 14, 2011 at 3:44 pm

    thank you, It solve my problem

  2. September 16, 2011 at 4:27 am

    You are welcome! Please keep visit blog 🙂

  3. surinder
    January 12, 2013 at 5:32 pm

    sorry these code not running on server.it run successfully on local.

    what step we done in go daddy any setting .

  4. surinder
    January 12, 2013 at 5:33 pm

    sorry these code not running on server.it run successfully on local.
    what step we done in go daddy any setting .

  5. January 12, 2013 at 6:13 pm

    You need to change mail server name when you upload to the server to ‘relay-hosting.secureserver.net’

  6. January 14, 2013 at 2:00 pm

    mail is running in local perfectly but we run on server it doesn’t run
    we allready change local server name…(:

    code below

    System.Net.Mail.MailMessage Mail = new MailMessage();
    Mail.From = new MailAddress(“sales@socailizedit.com”);

    if (ur.email.ToString() != “”)
    {
    Mail.Subject = Convert.ToString(“Query Sucessfully Registered”);
    Mail.To.Add(ur.email.ToString());
    //Mail.From = “vesturesupport01@vestureindia.com”;

    //string server = “relay-hosting.secureserver.net”;
    //string server = “smtp.gmail.com”;
    //Mail.To = ur.Email.ToString();
    //Mail.Cc = “ravi@vestureindia.com”;
    //Mail.Priority = System.Web.Mail.MailPriority.High;
    //Mail.BodyFormat = MailFormat.Html;
    //Mail.Body = strbuld.ToString();

    //SmtpMail.SmtpServer = server;

    //SmtpMail.Send(Mail);
    //Mail.Cc = “ravi@vestureindia.com”;
    Mail.IsBodyHtml = true;
    Mail.Body = strbuld.ToString();
    System.Net.Mail.SmtpClient smtp = new SmtpClient();
    smtp.Port = 587;
    smtp.Host = “smtp.gmail.com”;
    smtp.Credentials = new System.Net.NetworkCredential(“sales@socializedit.com”, “sales@123”);
    smtp.EnableSsl = true;
    smtp.Send(Mail);

    }
    strbuld.Remove(0, strbuld.Length);
    Mail = null;

  7. January 30, 2013 at 11:39 am

    Hi Surinder,

    In the above mentioned code, you specified smtp server as gmail. You need to change once you upload to server as I mentioned in the post.
    relay-hosting.secureserver.net

    Please try and let me know if you face any further issue

  8. May 11, 2013 at 10:57 pm

    Normally I don’t read article on blogs, however I would like to say that this write-up very forced me to check out and do it! Your writing style has been amazed me. Thank you, quite nice post.

  9. May 27, 2013 at 10:33 pm

    I tend not to create a bunch of remarks, but i did a few searching and wound up here How to send mail using
    Gmail in ASP.Net with Godaddy Server? | Tuvian :
    Discussion forum for ASP.Net,C#,Ajax,JQuery,JavaScript,HTML,CSS.
    .. And I actually do have a couple of questions for you if it’s allright. Is it just me or does it look as if like a few of the comments come across like they are left by brain dead individuals? 😛 And, if you are writing at additional social sites, I would like to keep up with anything fresh you have to post. Could you make a list of all of your communal pages like your linkedin profile, Facebook page or twitter feed?

  10. May 28, 2013 at 11:35 am

    Hi SharecashHack,
    Thanks for visiting our blog..
    Our Official site is http://www.tuvian.com

  11. September 3, 2013 at 12:15 pm

    hi my mail sending code is not working can u help me
    the hosting goddady ..in local it’s working .i change the relay-hosting.secureserver.net for sever said but it’s not working what can i do…

  12. September 3, 2013 at 7:43 pm

    Hi Vinathi,

    Can you please post your codes so that I can find issues and fix.

    Thanks

  1. No trackbacks yet.

Leave a comment